package com.qiku;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableEurekaClient
//@EnableCircuitBreaker  //开启熔断
@EnableFeignClients  //开启feign
public class PageApplication9991 {
    public static void main(String[] args) {
        SpringApplication.run(PageApplication9991.class,args);
    }

    @LoadBalanced  //启动负载均衡
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }


    @Bean
    public IRule getRandomRule() {
        return new RandomRule();//创建“随机”负载均衡策略,默认策略是“轮询”
    }


}
